package com.yiqi.lottery.feature.login.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.entity.bo.UserInfoBo;
import com.yiqi.lottery.entity.bo.RegisterBo;
import com.yiqi.lottery.feature.login.contract.RegisterContract;
import com.yiqi.lottery.feature.login.dependencies.register.DaggerRegisterModelComponent;
import com.yiqi.lottery.framework.api.ApiLib;
import com.yiqi.lottery.framework.api.UserApi;
import io.reactivex.Observable;

import javax.inject.Inject;

public class RegisterModel  implements RegisterContract.Model {

    @Inject
    UserApi api;


    @Inject
    public RegisterModel() {

        DaggerRegisterModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }

    @Override
    public Observable<UserInfoBo> userRegister(RegisterBo registerBo) {
        return api.userRegister(registerBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> userRegisterSendCode(String mobile) {
        return api.userRegisterSendCode(mobile).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> userResetPwd(RegisterBo registerBo) {
        return api.userResetPassword(registerBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}
